package gui.user;

import gui.GUI;

import java.awt.event.*;
import math.Vector2D;

/**
 * @author Ryan Hill
 */
public class User 
{
	/**
	 * Boolean data for different keys
	 */
	private int keycode;
	
	/**
	 * Mouse position and button, null when not being held down
	 */
	private Vector2D mouse;
	private int button;
	private boolean oneAction;
	
	private Vector2D mouseMove;
	
	/**
	 * Constructor
	 */
	public User()
	{
		oneAction = false;
		keycode = -1;
		button = -1;
		mouseMove = new Vector2D();
	}
	
	
	/**
	 * @return mouse location, null if not held down
	 */
	public Vector2D getMousePos()
	{
		return mouse;
	}
	
	public void doneWithMouse()
	{
		mouseRelease();
	}
	
	public Vector2D getMouseMove()
	{
		return mouseMove;
	}
	/**
	 * @return button on mouse being held down, -1 if not held down
	 */
	public int getButton()
	{
		return button;
	}
	
	/**
	 * Click the mouse and notify the user
	 * 
	 * @param b button clicked
	 * @param v location of mouse
	 */
	public void mouseClick( int b, Vector2D v )
	{
		button = b;
		mouse = v;
	}
	
	/**
	 * Release all mouse data
	 */
	public void mouseRelease()
	{
		button = -1;
		mouse = null;
	}
	
	public void mouseMove( Vector2D v )
	{
		mouseMove = v;
	}
	
	/**
	 * Press a key down and notify the user
	 * 
	 * @param key the key code for the key being pressed
	 */
	public void keyPressed( int key )
	{
		if (keycode < 0)
			oneAction = true;
		keycode = key;
		
		//temp
		if( keycode == KeyEvent.VK_ESCAPE )
			System.exit( 0 );
	}
	
	/**
	 * Release a key and notify the user
	 * 
	 * @param key the key code for the key being released
	 */
	public void releaseKey()
	{
		keycode = -1;
	}
	public int getKey()
	{
		return keycode;
	}
	public void releaseOneAction()
	{
		oneAction = false;
	}
	public boolean getOneAction()
	{
		return oneAction;
	}
}
